import { IPSAppModule } from '../ipsapp-module';
import { IPSApplication } from '../ipsapplication';
import { PSAppPortalViewImpl } from '../view/psapp-portal-view-impl';

export class PSAppPortletContainerViewImpl extends PSAppPortalViewImpl {
  protected psappmodule: IPSAppModule | null = null;

  getPSAppModule(): IPSAppModule | null {
    if (this.psappmodule != null) return this.psappmodule;
    const value = this.M.getPSAppModule;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappmodule = ipsapplication.findPSAppModule(value);
    }
    return this.psappmodule;
  }

  get psAppModule(): IPSAppModule | null {
    return this.getPSAppModule();
  }

  getPSAppModuleMust(): IPSAppModule {
    const value = this.getPSAppModule();
    if (value == null) {
      throw new Error('未指定应用模块');
    }
    return value;
  }
}
